package com.lmt_11;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.jar.JarEntry;

public class MapTest1 {
    public static void main(String[] args) {
        Map<String,Integer> map = new HashMap<>();
        map.put("手表",10);
        map.put("手表",20);
        map.put("手机",50);
        map.put("java",10);
        map.put("python",10);
        System.out.println(map);

        Map<Integer,String> tree = new TreeMap<>();
        tree.put(12,"aa");
        tree.put(45,"ff");
        tree.put(2,"mm");
        System.out.println(tree);

        System.out.println(map.size()); // 打印大小
        System.out.println(map.get("手机")); // 根据键获取 如果建不存在会返回null
        System.out.println(map.remove("手机")); // 删除手机
        boolean java = map.containsKey("java"); // 判断包括某个键
        System.out.println(map.containsValue(12)); // 判断包含某个值
        System.out.println(map.keySet()); // 获取全部建的集合
        System.out.println(map.values()); // 获取全部的值
        Map<String,Integer> map1 = new HashMap<>();
        map1.put("jj",25);
        map1.put("aa",23);
        map.putAll(map1); // 将map1的内容拷贝一份到map

    }
}
